package com.swh.cloud.biz.conf;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
import org.springframework.context.annotation.PropertySource;

/**
 * 使用Java config替代xml配置
 * 使用本地的db.properties配置文件
 * @author sangwenhao
 * @date 2016年12月20日
 */
//prefix 配置参数key的前缀
//@Configuration
//@ConfigurationProperties
//@PropertySource("classpath:db.properties")
public class DataSourceLocalProperties {

    // 对应配置文件里的配置键(mysqldb.datasource.url)
    public final static String DS = "mysqldb.datasource";
    
    @Value("${jdbc.driver}")
    private String driverClassName = "com.mysql.jdbc.Driver";

    @Value("${jdbc.url}")
    private String url;
    
    @Value("${jdbc.username}")
    private String user; //注意这里不能使用username
    
    @Value("${jdbc.password}")
    private String password;
    
    private int maxActive = 100;
    private int maxIdle = 8;
    private int minIdle = 8;
    private int initialSize = 10;
    private boolean testOnBorrow = false;
    private boolean testOnReturn = false;
    private String validationQuery;
    
    public String getDriverClassName() {
        return driverClassName;
    }
    public void setDriverClassName(String driverClassName) {
        this.driverClassName = driverClassName;
    }
    public String getUrl() {
        return url;
    }
    public void setUrl(String url) {
        this.url = url;
    }
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
    public int getMaxActive() {
        return maxActive;
    }
    public void setMaxActive(int maxActive) {
        this.maxActive = maxActive;
    }
    public int getMaxIdle() {
        return maxIdle;
    }
    public void setMaxIdle(int maxIdle) {
        this.maxIdle = maxIdle;
    }
    public int getMinIdle() {
        return minIdle;
    }
    public void setMinIdle(int minIdle) {
        this.minIdle = minIdle;
    }
    public int getInitialSize() {
        return initialSize;
    }
    public void setInitialSize(int initialSize) {
        this.initialSize = initialSize;
    }
    public boolean isTestOnBorrow() {
        return testOnBorrow;
    }
    public void setTestOnBorrow(boolean testOnBorrow) {
        this.testOnBorrow = testOnBorrow;
    }
    public boolean isTestOnReturn() {
        return testOnReturn;
    }
    public void setTestOnReturn(boolean testOnReturn) {
        this.testOnReturn = testOnReturn;
    }
    public String getValidationQuery() {
        return validationQuery;
    }
    public void setValidationQuery(String validationQuery) {
        this.validationQuery = validationQuery;
    }
	public String getUser() {
		return user;
	}
	public void setUser(String user) {
		this.user = user;
	}
}
